﻿<UserControl x:Class="TodoList.View.EditControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             x:Name="editCtrl"
             xmlns:Converter="clr-namespace:TodoList.Converter"
             d:DesignHeight="145" d:DesignWidth="600">
    <UserControl.Resources>
        <Converter:TodoEditConverter x:Key="editConvert" />
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Foreground" Value="WhiteSmoke" />
        </Style>
    </UserControl.Resources>

    <Expander Margin="2" ExpandDirection="Down" 
              Foreground="Goldenrod" FontWeight="Black" FontSize="12"
                  IsExpanded="True" Header=" Edit Tasks" >
        <StackPanel>
            <Grid ShowGridLines="False">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition Width="180" />
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition Width="180" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="25" />
                    <RowDefinition Height="50" />
                    <RowDefinition Height="25" />
                    <RowDefinition Height="25" />
                </Grid.RowDefinitions>
                <TextBlock Text="Title" Grid.Column="0" Grid.Row="0" Margin="2"  />
                <TextBlock VerticalAlignment="Center" Text="Description" Grid.Column="0" Grid.Row="1" Margin="2" />
                <TextBlock Text="Due Date" Grid.Column="0" Grid.Row="2" Margin="2" />

                <TextBox Grid.Column="1" Grid.Row="0" Margin="2" 
                         Text="{Binding Path=Todo.Title, ValidatesOnDataErrors=True, 
	UpdateSourceTrigger=PropertyChanged}"  />
                <TextBox Grid.Column="1" Grid.Row="1" Margin="2" 
                         Height="45"
                         TextWrapping="Wrap" AcceptsReturn="True" ToolTip="{Binding Path=Todo.Description}"
                         Text="{Binding Path=Todo.Description}" />
                <DatePicker Grid.Column="1" Grid.Row="2" Margin="2" Text="{Binding Path=Todo.DueDate}" />

                <TextBlock Text="CompletedStatus" Grid.Column="2" Grid.Row="0" Margin="2" />
                <TextBlock VerticalAlignment="Center" Text="State" Grid.Column="2" Grid.Row="1" Margin="2" />
                <TextBlock Text="Priority" Grid.Column="2" Grid.Row="2" Margin="2" />

                <ComboBox Grid.Column="3" Grid.Row="0" Margin="2" SelectedIndex="{Binding Path=Todo.CompletedStatus}" >
                    <ComboBoxItem>0%</ComboBoxItem>
                    <ComboBoxItem>25%</ComboBoxItem>
                    <ComboBoxItem>50%</ComboBoxItem>
                    <ComboBoxItem>75%</ComboBoxItem>
                    <ComboBoxItem>100%</ComboBoxItem>
                </ComboBox>
                <ComboBox Grid.Column="3" Grid.Row="1" Margin="2" Height="25" VerticalAlignment="Top" SelectedIndex="{Binding Path=Todo.State}" >
                    <ComboBoxItem>Not Started</ComboBoxItem>
                    <ComboBoxItem>In Progress</ComboBoxItem>
                    <ComboBoxItem>Completed</ComboBoxItem>
                    <ComboBoxItem>Defered</ComboBoxItem>
                </ComboBox>
                <ComboBox Grid.Column="3" Grid.Row="2" Margin="2" SelectedIndex="{Binding Path=Todo.Priority}" >
                    <ComboBoxItem>Immediate</ComboBoxItem>
                    <ComboBoxItem>Medium</ComboBoxItem>
                    <ComboBoxItem>Low</ComboBoxItem>
                    <ComboBoxItem>Normal</ComboBoxItem>
                </ComboBox>

                <Button Content="Save" Grid.Column="3" Grid.Row="3"                        
                        
                        Command="{Binding Path=EditSaveAction}" >
                    <Button.CommandParameter>
                        <MultiBinding Converter="{StaticResource ResourceKey=editConvert}">                           
                            <Binding ElementName="editCtrl" />
                            <Binding />
                        </MultiBinding>
                    </Button.CommandParameter>
                </Button>
                
            </Grid>
            <StackPanel Margin="2,10,2,2" Height="2" Background="GreenYellow" ></StackPanel>
        </StackPanel>
    </Expander>
</UserControl>
